/**
 * git do not control webim.config.js
 * everyone should copy webim.config.js.demo to webim.config.js
 * and have their own configs.
 * In this way , others won't be influenced by this config while git pull.
 *
 */

// for react native
// var location = {
//     protocol: "https"
// }

function getUrl(){
    var apiUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com'
    var socketUrl = '//im-api-v2.easemob.com/ws'
    if(window.location.href.indexOf('webim-h5.easemob.com') !== -1 ){
        apiUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com'
        socketUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//im-api-v2.easemob.com/ws'
    }
    else if(window.location.href.indexOf('webim-hsb-ly.easemob.com') !== -1){
        apiUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//a1-hsb.easemob.com'
        socketUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//im-api-v2-hsb.easemob.com/ws'
    }
    else if(window.location.href.indexOf('localhost') !== -1){
        apiUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//a1.easemob.com'
        socketUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//im-api-v2.easemob.com/ws'
    }
    return {
        apiUrl: apiUrl,
        socketUrl: socketUrl,
        sandBoxApiUrl: 'https://a1-hsb.easemob.com',
        sandboxSocketUrl: 'https://im-api-v2-hsb.easemob.com/ws'
    }
}


var config = {
    socketServer: '//im-api-v2.easemob.com/ws',    // socket Server地址

    restServer: '//a1.easemob.com',               // rest Server地址

    appkey: '1101200831148507#ycgm',        // App key

    https : window.location.protocol === 'https:',                            // 是否使用https

    isWebRTC: true,

    isHttpDNS: true,                          // 3.0 SDK支持，防止DNS劫持从服务端获取XMPPUrl、restUrl

    isMultiLoginSessions: false,              // 是否开启多页面同步收消息，注意，需要先联系商务开通此功能

    isDebug: false,                           // 打开调试，会自动打印log，在控制台的console中查看log

    autoReconnectNumMax: 2,                   // 断线重连最大次数

    heartBeatWait: 30000,                     // 心跳间隔（只在小程序中使用）

    delivery: false,                           // 是否发送已读回执

    useOwnUploadFun: false,                    // 是否使用自己的上传方式（如将图片文件等上传到自己的服务器，构建消息时只传url）

    britecloud: 'britecloud'                   //自定义参数，用于房间名和房间密码等
}
export default config
